package cn.patpang.core.framework.hibernate;

import java.io.Serializable;
import java.util.Map;

/**
 * @Title BaseDaoView.java
 * @Author PangPX
 * @Data 2017年6月8日 下午2:50:56
 */
public class BDParam implements Serializable {

	private static final long serialVersionUID = -2271450224220003105L;
	public static final Integer FINAL_LIMIT = 10;

	private Integer start = 0;
	private Integer limit = FINAL_LIMIT;
	private BDSort[] sorts;
	private BDCondition[] conditions;
	private BDMultiCondition[] multiConditions;
	private Map<String, Object> reParams;
	private boolean nil = false;

	private BDParam() {
		start = null;
		limit = null;
		nil = true;
	}

	private BDParam(Integer start, Integer limit, BDSort[] sorts, BDCondition[] conditions, BDMultiCondition[] multiConditions) {
		super();
		this.start = start;
		this.limit = limit;
		this.sorts = sorts;
		this.conditions = conditions;
		this.multiConditions = multiConditions;
	}

	public static BDParam setSimple(BDSort sort, BDCondition condition) {
		return new BDParam(0, FINAL_LIMIT, new BDSort[] { sort }, new BDCondition[] { condition }, null);
	}

	public static BDParam setSimple(BDSort sort, BDCondition condition, BDMultiCondition multiCondition) {
		return new BDParam(0, FINAL_LIMIT, new BDSort[] { sort }, new BDCondition[] { condition }, new BDMultiCondition[] { multiCondition });
	}

	public static BDParam set(BDCondition condition) {
		return new BDParam(0, FINAL_LIMIT, null, new BDCondition[] { condition }, null);
	}

	public static BDParam set(BDCondition... conditions) {
		return new BDParam(0, FINAL_LIMIT, null, conditions, null);
	}

	public static BDParam set(BDSort[] sorts, BDCondition... conditions) {
		return new BDParam(0, FINAL_LIMIT, sorts, conditions, null);
	}

	public static BDParam set(BDSort[] sorts, BDCondition[] conditions, BDMultiCondition[] multiConditions) {
		return new BDParam(0, FINAL_LIMIT, sorts, conditions, multiConditions);
	}

	public static BDParam set(BDCondition[] conditions, BDMultiCondition[] multiConditions) {
		return new BDParam(0, FINAL_LIMIT, null, conditions, multiConditions);
	}

	public static BDParam set(Integer start, Integer limit, BDCondition... conditions) {
		return new BDParam(start, limit, null, conditions, null);
	}

	public static BDParam set(Integer start, Integer limit, BDSort[] sorts, BDCondition[] conditions) {
		return new BDParam(start, limit, sorts, conditions, null);
	}

	public static BDParam set(Integer start, Integer limit, BDSort[] sorts, BDCondition[] conditions, BDMultiCondition[] multiConditions) {
		return new BDParam(start, limit, sorts, conditions, multiConditions);
	}

	public boolean isNil() {
		return nil;
	}

	public static BDParam nil() {
		return new BDParam();
	}

	public Integer getStart() {
		return start;
	}

	public Integer getLimit() {
		return limit;
	}

	public BDSort[] getSorts() {
		return sorts;
	}

	public BDCondition[] getConditions() {
		return conditions;
	}

	public BDMultiCondition[] getMultiConditions() {
		return multiConditions;
	}

	public Map<String, Object> getReParams() {
		return reParams;
	}

	public void setReParams(Map<String, Object> reParams) {
		this.reParams = reParams;
	}

}
